
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class Base1():

    def __init__(self,driver :webdriver):
        self.driver = driver


    def open_url(self,url):
        self.driver.get(url)

    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,20,0.5).until(EC.presence_of_element_located(loc))
            return self.driver.find_element(*loc)
        except Exception as e:
            print(e)
            print("未定位到元素:",loc)
    #点击
    def click(self,loc):
        self.find_element(loc).click()
    #输入
    def send_keys(self,loc,text):
        self.find_element(loc).send_keys(text)
    #获取文本属性方法
    def get_text(self,loc):
        return self.find_element(loc).text
